package SimpleSelectionSort;
//简单选择排序
import java.util.Random;

public class sort03 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] a = new int[10];
        for (int i = 0; i < a.length; i++) {
            a[i] = random.nextInt(100);
        }
        for (int i : a) {
            System.out.print(i + "   ");
        }
        System.out.println();
        sort(a);
        for (int ints : a) {
            System.out.print(ints + "   ");
        }
    }

    public static void sort(int[] a)
    {
        for(int i=0;i<a.length-1;i++)
        {
            int t=i,min=a[i];
            for(int j=i;j<a.length;j++)
            {
                if(a[j]<min) {
                    min=a[j];
                    t = j;
                }
            }
            int p=a[i];
            a[i]=a[t];
            a[t]=p;
        }
    }
}
